﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<p>
    <label class="i" for="Abstract">
        地点：
    </label>
    <input type="text" id="Location" name="InnerLocation" class="text w300" 
    title="请输入地点..." autocomplete="off"  />
</p>

<script type="text/javascript" charset="utf-8">
    $(function () {
        var valueSelected = false;
        acPipes = cy.ui.autoComplete({
            eleId: 'Location',
            itemClicked: function (item) {
                $("#Location").val(item.name);
                valueSelected = true;
            },
            valueChanged: function (text) {
                if (text.length < 1 || valueSelected) {
                    return;
                }
                $.ajax({
                    url: '<%= Url.Action("SearchLocation","Home") %>',
                    data: { s: text },
                    dataType: "json",
                    type: "get",
                    success: function (data, textStatus) {
                        if (data.success && data.list !== null) {
                            if (data.list) {
                                acPipes.setItems(data.list);
                            } else {
                                acPipes.setItems([]);
                            }
                        }
                    }
                });
            },
            initText: '',
            maxHeight: 168 // 21的倍数
        });

        $("#TxtPipeType").bind("keydown", function (e) {
            if (valueSelected && e.keyCode === 8) {
                valueSelected = false;
                $("#Location").val('');
                e.preventDefault();
            }
        });
    });
</script>
